package com.gz.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.gz.bean.XmlBean;
import com.gz.utils.ConfigXMLUtils;

public class ActionListener implements ServletContextListener {

	public ActionListener() {

	}

	/**
	 * @see ServletContextListener#contextInitialized(ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent event) {
		ServletContext context = event.getServletContext();
		String xmlPath = context.getInitParameter("config");
		String tomcatPath = context.getRealPath("\\");
		try {
			Map<String, XmlBean> map = ConfigXMLUtils.processXML(tomcatPath + xmlPath);
			context.setAttribute("configInit", map);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent event) {
	}

}
